package com.bingfor.easycablelink.my;

import android.content.Intent;
import android.databinding.ObservableInt;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import com.bingfor.easycablelink.R;
import com.bingfor.easycablelink.base.BaseActivity;
import com.bingfor.easycablelink.base.BaseRecyclerViewActivity;
import com.bingfor.easycablelink.databinding.BaseRecyclerviewBinding;

public class AddressListActivity extends BaseRecyclerViewActivity {

    BaseRecyclerviewBinding binding;
    AddressListAdapter adapter = new AddressListAdapter();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = BaseRecyclerviewBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        initToolbar();
    }

    @Override
    public void initToolbar() {
        Toolbar toolbar = $(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        setTitle("收货地址管理");
        initViews();
    }

    @Override
    public void refresh() {

    }

    @Override
    public void reload() {

    }
    @Override
    public void initViews() {
        super.initViews();
        binding.setStatus(new ObservableInt(1));
        pageStatus.set(PAGE_STATUS_SHOW);
        mRecyclerView.setLayoutManager(mLayoutManager = new LinearLayoutManager(mContext));
//        mRecyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL));
        mRecyclerView.setAdapter(adapter);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu_right_post_address, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_post:
                moveToNextPage(AddAddressActivity.class);
               showSnakeBar("添加地址.");
                break;
        }
        return super.onOptionsItemSelected(item);
    }
}
